Winnovative Software Logo

 HTML to PDF Converter - Excel Library - ASP.NET Charts - RTF to PDF Converter
 PDF Merge and Split - PDF Security - PDF Viewers - PDF to Text - Images Extractor

 
Skip Navigation Links
 
In the code samples below you can see how the converter is used in a ASP.NET page to render a PDF document from a specified URL and send the PDF document bytes to the client browser. A similar code can be used in windows forms and console applications. The library offers methods for converting RTF strings and RTF files to PDF documents.

C# Code - Sample RTF to PDF Converter

1:     protected void btnConvert_Click(object sender, EventArgs e)
2:     {
3:         PdfConverter pdfConverter = new PdfConverter();
4:  
5:         pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
6:         pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait;
7:         pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal;
8:  
9:         
10:  
11:        pdfConverter.PdfDocumentOptions.ShowFooter = false;
12:        pdfConverter.PdfDocumentOptions.ShowHeader = false;
13:  
14:        pdfConverter.LicenseKey = "MyLicenseKeyString";
15:  
16:        byte[] downloadBytes = pdfConverter.GetPdfBytesFromRtfString(MyRTFString);        
17:  
18:        System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
19:        response.Clear();
20:        response.AddHeader("Content-Type", "binary/octet-stream");
21:        response.AddHeader(
                        "Content-Disposition",
22:             "attachment; filename=" + "Rendered.pdf" + "; size=" 
                + downloadBytes.Length.ToString());
23:        response.Flush();
24:        response.BinaryWrite(downloadBytes);
25:        response.Flush();
26:        response.End();
27:     }

VB.NET Code Sample - RTF to PDF Converter

1:     Protected Sub btnConvert_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
Handles btnConvert.Click
2:         Dim pdfConverter As PdfConverter = New PdfConverter
3:  
4:         pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4
5:         pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait
6:         pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal
7:  
8:         
9:  
10:        pdfConverter.PdfDocumentOptions.ShowHeader = False
11:        pdfConverter.PdfDocumentOptions.ShowFooter = False
12:         
13:        pdfConverter.LicenseKey = "MyLicenseKeyString";
14:        Dim downloadBytes() As Byte = pdfConverter.GetPdfBytesFromRtfString(MyRTFString);
15:  
16:        Dim response As System.Web.HttpResponse = System.Web.HttpContext.Current.Response
17:  
18:        response.Clear()
19:        response.AddHeader(
                        "Content-Type", "binary/octet-stream")
20:        response.AddHeader("Content-Disposition", ("attachment; filename=" _
21:                         + (
                        "Rendered.pdf" + ("; size=" + downloadBytes.Length.ToString))))
22:        response.Flush()
23:        response.BinaryWrite(downloadBytes)
24:        response.Flush()
25:        response.End()
26:  
27:     End Sub